package br.edu.ufcg.lsd.wbis.ui.client.ui.management;

import br.edu.ufcg.lsd.wbis.ui.client.beans.RootCreationStatus;

import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * @author Renato Miceli
 */
public class RootUserStatusGetterCallback implements AsyncCallback<RootCreationStatus> {

	private final PanelManager panelManager;

	public RootUserStatusGetterCallback(PanelManager panelManager) {
		this.panelManager = panelManager;
	}

	/**
	 * {@inheritDoc}
	 */
	public void onFailure(Throwable caught) {
		this.panelManager.switchToLoginPanel();
	}

	/**
	 * {@inheritDoc}
	 */
	public void onSuccess(RootCreationStatus result) {
		if (result.equals(br.edu.ufcg.lsd.wbis.ui.client.beans.RootCreationStatus.NOT_CREATED)) {
			this.panelManager.switchToSetupPanel();
		} else {
			this.panelManager.switchToLoginPanel();
		}
	}

}
